package com.lh.tams.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lh.tams.domain.TamsPerson;
import com.lh.tams.service.system.PersonService;
import com.lh.tams.util.Constants;
import com.lh.tams.util.diy.Json;

@RequestMapping("/login")
@Controller
public class LoginController {
	private PersonService personService;

	public void setPersonService(PersonService personService) {
		this.personService = personService;
	}
	
	@RequestMapping("/login.adm")
	@ResponseBody
	public Json login(HttpSession session, String personUsername,String personPassword){
		TamsPerson person=personService.login(personUsername, personPassword);
		session.setAttribute(Constants.ADMIN_SESSION_KEY, person);
		return new Json();
	}
	
	@RequestMapping("/logout.adm")
	public String logout(HttpSession session){
		session.invalidate();//session失效
		return "pages/login";
	}
	
	
	
	
}
